def Quadratic(x):  # 定义二次函数
    return 2 * x ** 2 + 3 * x + 4


import numpy as np
import matplotlib.pyplot as plt



def plot_ladder(laddernum):
    x = np.linspace(-5, 5, num=100)#确定x值
    y = Quadratic(x)#确定y值
    plt.plot(x, y)#画出函数

    a = np.linspace(-5, 5, num=laddernum)#确定a的值，从-5到+5，间隔为；laddernum
    for i in range(laddernum):
        plt.plot([a[i], a[i]], [0, Quadratic(a[i])], color="black")  # 画梯形的上底和下底

    
    plt.legend()
    plt.xlabel('independent variable')
    plt.ylabel('dependent variable')
    plt.show()
    # 将图像表示出来

plot_ladder(30)  